#include <STC15F2K60S2.h>
#include <iic.h>
#include <absacc.h>
unsigned char i;
unsigned char m;
unsigned char inter;
unsigned char ad_dat;
bit read_da;
void Delay1ms();
void display(void);
code unsigned char tab[] = { 0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,
                             0xff
                           };
unsigned char dspbuf[8] = {10,10,10,10,10,10,10,10};  
void Timer0Init(void);


void main()
{
	
	Timer0Init();
	while(1)
	{
		if(read_da)
		{
			read_da=0;
		ad_dat=read_dress(0x43);
		
		(ad_dat>=100)?(dspbuf[5]=ad_dat/100):(dspbuf[5]=10);
		(ad_dat>=10)?(dspbuf[6]=ad_dat/10%10):(dspbuf[6]=10);
		dspbuf[7]=ad_dat%10;
		}
		
	}
}
void Timer0Init(void)		//1??@12.000MHz
{
	AUXR &= 0x7F;		//?????12T??
	TMOD &= 0xF0;		//???????
	TL0 = 0x18;		//??????
	TH0 = 0xFC;		//??????
	TF0 = 0;
ET0=1;
EA=1;	//??TF0??
	TR0 = 1;		//???0????
}


void time_isr()interrupt 1
{
	if(++inter==50)
	{read_da=1;}
	display();
}




void display(void) 
{
	P2 =((P2&0x1F)|0xc0);
	P0 = (1<<i);
	P2&= 0x1F;
 P2 =((P2&0x1F)|0xe0);
	P0 = 0xFF;
	
	P0 = tab[dspbuf[i]];
  P2&= 0x1F;
	if(++i==8)
	{
		i=0;
	}
}

void Delay1ms()		//@12.000MHz
{
	unsigned char i, j;

	i = 2;
	j = 239;
	do
	{
		while (--j);
	} while (--i);
}

